package Day06;

import java.util.Scanner;

public class GirlFriendsText {
    public static void main(String[] args) {
        GirlFrends[] arr = new GirlFrends[4]; //对象数组

        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < arr.length; i++) {
            GirlFrends g = new GirlFrends();

            System.out.println("可否告知在下，姑娘你的芳名?");
            String name = sc.next();
            g.setName(name);

            System.out.println("菇凉，你几岁啦？");
            int age = sc.nextInt();
            g.setAge(age);

            System.out.println("姑娘是否是女儿身？性别是？");
            String gender = sc.next();
            g.setGender(gender);

            System.out.println("姑娘，平时可有何喜好？");
            String hobby = sc.next();
            g.setHobby(hobby);

            arr[i] = g;
        }


        int sum = 0;
        for (int i = 0; i < arr.length; i++) {
            sum += arr[i].getAge();
        }
        int avg = sum / arr.length;

        System.out.println("所有女友 的平均年龄是" + avg);

        for (int i = 0; i < arr.length; i++) {
            if(arr[i].getAge() < avg){
                System.out.println(arr[i].getName() + ", " + arr[i].getAge() + ", "
                        + arr[i].getGender()+ ", " + arr[i].getHobby());

            }
        }
        System.out.println("以上是低于平均年龄的女友噢");

    }
}
